function upTime(){
	var cDate = new Date();
	if (cDate.getMinutes()<10){
		mm = '0' + cDate.getMinutes();
	} else { mm = cDate.getMinutes(); };
	$('#time').html(cDate.getHours() + ":" + mm);
	$('#date').html(cDate.getMonth()+1 + "月" + cDate.getDate() + "日");
	var days = ["日","一","二","三","四","五","六"];
	$('#day').html("星期" + days[cDate.getDay()]);
};
function showCharm(){
	$('#charm').fadeIn('fast');
	$('#charm2').fadeIn('fast');
	$tid = setTimeout("hideCharm();",15000);
}
function hideCharm(){
	$('#charm').fadeOut('fast');
	$('#charm2').fadeOut('fast');
	clearTimeout($tid);
}
function showPanel(id){
	$('#'+id).animate({width:'350px'},'fast');
}
function hidePanel(id){
	$('#'+id).animate({width:'0px'},'fast');
}
$(function(){
	if (localStorage.color){
		$('.bg').css('background-color',localStorage.color);
	}
	upTime();
	setInterval("upTime();",30000);
	//charm start
	$('#charm_touch').mouseenter(showCharm);
	$('#charm').mouseleave(hideCharm);
	$("div[id^='charm__']").mouseenter(function(){
		$(this).css('background-color','#333');
	}).mouseleave(function(){
		$(this).css('background-color','');
	});
	$('#charm__start').click(function(){
		window.location.href='/';
	});
	$('#charm__share').click(function(){
		showPanel('p_share');
		$('#shareinfo').html('<strong>'+document.title+'</strong><br />'+document.URL);
	});
	$('#charm__more').click(function(){
		showPanel('p_more');
	});
	//charm end
	$('.back').mousedown(function(){
		$(this).attr('class','back back2');
	}).mouseup(function(){
		$(this).attr('class','back back1');
		hidePanel($(this.parentElement).attr('id'));
	});
	$('.more_btn').mouseenter(function(){$(this).css('background','rgba(255,255,255,.2)');})
	.mouseleave(function(){$(this).css('background','rgba(255,255,255,0)');})
	.click(function(){hidePanel('p_more');showPanel($(this).attr('p'));});
});